home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 735 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.4 KB  |  107 lines

  1. Path: news.hi.net!anjo!amcleod
  2. Distribution: world
  3. Newsgroups: comp.lang.c
  4. From: amcleod@anjo.hi.net (Angus Mcleod)
  5. X-Mailer: NetXpress 1.53
  6. Date: Mon, 08 Jan 1996 14:27:00 -0640
  7. Organization: The ANJO BBS
  8. Subject: Where am I going wrong?
  9. Message-ID: <414.1168.52@anjo.hi.net>
  10.  
  11. I'm trying to create an OS/2 .DLL with functions I can call from REXX.
  12. Here is my super-simple trial source:
  13.  
  14.      #define INCL_REXXSAA
  15.      #include <rexxsaa.h>
  16.      #include <string.h>
  17.  
  18.      #define REXX_FAIL   40       /* raise Rexx error */
  19.      #define REXX_OK     0        /* successful completion */
  20.  
  21.      /* declare exported REXX function */
  22.      RexxFunctionHandler MyRexxFunc;
  23.  
  24.      /* a useful macro */
  25.      #define MAKE_REXX_STR(t, s) { \
  26.          strcpy((t)->strptr,(s));\
  27.          (t)->strlength = strlen((s)); \
  28.      }
  29.  
  30.      /* function: MyRexxFunc */
  31.      ULONG MyRexxFunc(CHAR *name, ULONG numargs, RXSTRING args[],
  32.             CHAR *queuename, RXSTRING *retstr) {
  33.  
  34.          char str[256] = "SUCCESS";      /* dummy result */
  35.  
  36.          MAKE_REXX_STR(retstr, str);     /* pass back result */
  37.          return REXX_OK;                 /* no error on call */
  38.      }
  39.  
  40.  
  41. Couldn't be simpler, I'd have thought!  I compile this, link the REXX.LIB
  42. and end up with MYRXDLL.DLL on the disk.  Here's the output from the Watcom
  43. IDE Log.
  44.  
  45. cd e:\watcom\hw
  46. wmake -f e:\watcom\hw\myrxdll.mk -h -e e:\watcom\hw\myrxdll.dll
  47. wcc386 myrxdll.c -i=F:\h;F:\h\os2 -w4 -e25 -zq -otexan -d2 -bd -5r -bt=os2 -mf
  48. wlink d all SYS os2v2 dll op m op maxe=25 op q op symf op one @myrxdll.lk1
  49. wlib -n -b myrxdll.lib +myrxdll.dll
  50. WATCOM Library Manager Version 10.5
  51. Copyright by WATCOM International Corp. 1988, 1995. All rights reserved.
  52. WATCOM is a trademark of WATCOM International Corp.
  53. Execution complete
  54.  
  55. Now I run my TEST.CMD program to see if it works.  Here it is:
  56.  
  57.     /* REXX! */
  58.  
  59.     rc = RxFuncAdd( 'MyRexxFunc', 'MyRxDll', 'MyRexxFunc' );
  60.     say "RxFuncAdd returned " rc
  61.  
  62.     rc = RxFuncQuery( 'MyRexxFunc' );
  63.     say "RxFuncQuery( 'MyRexxFunc' ); returned " rc
  64.  
  65.     rc = MyRexxFunc()
  66.     say "MyRexxFunc() returned " rc
  67.  
  68. And here is the result:
  69.  
  70. [E:\WATCOM\HW]test
  71. RxFuncAdd returned  0
  72. RxFuncQuery( 'MyRexxFunc' ); returned  0
  73.      9 +++   rc = MyRexxFunc();
  74. REX0043: Error 43 running E:\watcom\hw\TEST.CMD, line 9: Routine not found
  75.  
  76. [E:\WATCOM\HW]
  77.  
  78. According to this, the function was successfully added (RxFuncAdd returned 0)
  79. and was found by RxFuncQuery (which also returned 0).  Yet, line #9 halts with
  80. error 43.
  81.  
  82. So where am I going wrong?  The DLL appeared to compile, and my function even
  83. appeared to be added OK by RxFuncAdd, but...
  84.  
  85. Oh yes - just to make matters easier, if I try to re-compile the source,
  86. I'm told the .DLL is in use and I get denied access.  Example:
  87.  
  88.     [E:\WATCOM\HW]del *.dll
  89.     E:\watcom\hw\MYRXDLL.DLL
  90.     SYS0032: The process cannot access the file because it is being used
  91.     by another process.
  92.  
  93.     [E:\WATCOM\HW]help 32
  94.  
  95.     SYS0032: The process cannot access the file because it is being used
  96.     by another process.
  97.  
  98.     EXPLANATION: The file is already being used by another process.
  99.  
  100.     ACTION: Retry the command later.
  101.  
  102. Surely I don't have to re-boot the machine in order to free up access to
  103. the .DLL so I can recompile it?
  104. .- -. .--- ---   .- -. .--- ---   .- -. .--- ---   .- -. .--- ---
  105. Internet: amcleod@anjo.hi.net (Angus Mcleod)
  106. Origin:   The ANJO BBS
  107.